#include <stdio.h>
#include <gmp.h>
#include <mpfr.h>

int main()
{
  unsigned int i;
  mpfr_t s, t, u;

  //int size = sizeof(__mpfr_struct);
  //size = sizeof(t->_mpfr_prec);
  //size = sizeof(t->_mpfr_sign);
  //size = sizeof(t->_mpfr_exp);
  //size = sizeof(t->_mpfr_d);
  //size = sizeof(mpfr_prec_t);

  mpfr_init2 (t, 200);
  mpfr_set_d (t, 1.0, GMP_RNDD);
  mpfr_init2 (s, 200);
  mpfr_set_d (s, 1.0, GMP_RNDD);
  mpfr_init2 (u, 200);
  for (i = 1; i <= 1000000; i++)
  {
    mpfr_mul_ui (t, t, i, GMP_RNDU);
    mpfr_set_d (u, 1.0, GMP_RNDD);
    mpfr_div (u, u, t, GMP_RNDD);
    mpfr_add (s, s, u, GMP_RNDD);
  }
  printf ("Sum is ");

  char* buf = new char[2048];
  mpfr_snprintf(buf, 2048, "%.2000Rg", s);
  printf(buf);

  putchar ('\n');
  printf("%d\n", sizeof(size_t));

  mpfr_init2(t, 200);
  mpfr_set_str(t, "123", 10, GMP_RNDD);
  mpfr_snprintf(buf, 2048, "%.2000Rg", t);
  printf(buf);

  mpfr_asin(t, s, GMP_RNDD);
  mpfr_acos(t, s, GMP_RNDD);

  mpfr_abs(t,s,GMP_RNDD);

  double doub;

  printf("%d\n", sizeof(mpfr_get_default_prec()));

  delete [] buf;

  mpfr_clear (s);
  mpfr_clear (t);
  mpfr_clear (u);

  printf("long double %d\n", sizeof(long double));
  printf("double %d\n", sizeof(double));

  return 0;
}
